//class for a linked list of HObjects
//TODO: this class needs to be rewritten to use the std library
//It is usefull for keeping track of verious parts/assets of the engine

#ifndef _HELIX_LINKED_LIST_H_
#define _HELIX_LINKED_LIST_H_

#include "Helix.h"
#include "HObject.h"
#include "Log.h"

namespace helix		//Put this in the helix namespace
{

	class MY_CLASS ListNode : public HObject			//node class for the linked list
	{
	public:
		HObject* obj;					//pointer to the object in the node
		ListNode* next;				//pointer to the next node in the list

		ListNode();					//constructor
		ListNode(HObject* object);		//initializes obj to object
		ListNode(HObject* object, ListNode* nextObj);
		virtual ~ListNode();
	};


	class MY_CLASS LinkedList : public HObject		//linked list class extends HObject class
	{
	protected:
		ListNode head;					//the first node in the list
		int length;						//the number if nodes in the list
		int position;					//the current position in the list
		ListNode *curNode;				//pointer to the current node in the list

	public:
		LinkedList();
		virtual ~LinkedList();

		void AddFirst(HObject* obj);	//adds a link to the object at the beginning of the list
		void AddMiddle(HObject* obj,int pos);	//adds a link to an arbitrary position in the list
		void AddLast(HObject* obj);		//adds a link to the object at the end of the list
		void Delete(int position);		//deletes the object and the link to the object in the specified position
		void Delete(HObject *obj);      //search for a specific object and delete it
		void Delete();					//delete the current object
		int Length();

		HObject* Remove();				//remove the current object from the list
		HObject* Remove(HObject *obj);	//search and remove object
		HObject* GetObj(int pos);		//returns the object in the specified position
		HObject* GetObj();				//returns the current object
		HObject* Next();				//move to the next object
		HObject* First();				//set the position and return the first object

		bool Contains(HObject *obj);

		int IndexOf(HObject *obj);

		virtual void Print();			//calls all the objects print functions and prints them to the log file
	};

}  //End the helix namespace


#endif
